<?php
/**
 * Created by IntelliJ IDEA.
 * User: admin
 * Date: 2020/12/10
 * Time: 15:31
 */

namespace app\common\model;
use think\Db;
use think\Model;

class OrderModel extends Model
{

    protected $name='orders';
    public function add($arr){
        return self::insert($arr);
    }
    public function getOrderListByUserId($user_id,$status){

        $where = [['user_id','=',$user_id]];
//        if($status){
            $where[] = ['order_status','=',$status];
//        }
        return self::where($where)->order('id','desc')->field('id,total_money,is_appraise,total_integral,order_number,type_name,address_name,floor_address,address_type,
        phone,true_name,create_time,appointment_date,appointment_time,order_status,region_name,accept_user_name,accept_user_phone,all_type')->select();
    }
    public function cannelOrder($user_id,$order_id){
        return self::where('id',$order_id)->where('user_id',$user_id)->update(['order_status'=>6]);
    }
}